package com.tedu.activity.dao;

import com.tedu.activity.pojo.Activity;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author Song
 * @since 2020/10/9
 */
@Mapper

public interface ActivityDao {

    @Select("select * from tb_activity order by createdTime desc")
    List<Activity> findActivitys();

    @Insert("insert into tb_activity (title,category,startTime,endTime,remark,state,createdUser,createdTime) values (#{title},#{category},#{startTime},#{endTime},#{remark},#{state},#{createdUser},now())")
    @Options(useGeneratedKeys = true,keyProperty = "id")
    int insertObject(Activity activity);

    @Update("update tb_activity set state=0 where id=#{id}")
    int updateState(Long id);

    @Delete("delete from tb_activity where id=#{id}")
    int deleteObject(Long id);
}
